package generic.net.observers;

import generic.net.Peer;
import java.util.Vector;

/**
 *
 * @author Adam Scarr <scarr.adam@gmail.com>
 */
public class PeerConnectDispatcher {
    private Vector<PeerConnectObserver> observers = new Vector<PeerConnectObserver>();

    public synchronized void add(PeerConnectObserver observer) {
        observers.add(observer);
    }

    public synchronized void remove(PeerConnectObserver observer) {
        observers.remove(observer);
    }

    public synchronized void notifyPeerConnect(Peer peer) {
        for (PeerConnectObserver observer: observers) {
            observer.peerConnect(peer);
        }
    }

    public synchronized int size() {
        return observers.size();
    }
}
